package com.contory.ssn_lgnd.app.maingame;

import com.contory.ssn_lgnd.app.Assets;
import com.contory.ssn_lgnd.app.comp.DrawPtr;
import com.contory.ssn_lgnd.app.comp.UpdatePtr;
import com.contory.ssn_lgnd.app.comp.ViewObject;
import com.contory.ssn_lgnd.framework.gl.SpriteBatcher;
import com.contory.ssn_lgnd.framework.gl.TextureRegion;
import com.contory.ssn_lgnd.framework.math.Vector2;

public class Particle implements UpdatePtr, DrawPtr{
	ViewObject view;
	Vector2 dir;
	float initW, initH;
	float stateTime = 0;
	boolean enableBool = true;
	byte state = 0;
	
	public Particle(float w, float h, TextureRegion tr){
		view = new ViewObject();
		//tr, w, h init
		view.w = w; view.h = h; view.tr = tr;
		initW = w; initH = h;
		dir = new Vector2();
	}
	
	public void init(Vector2 dir, float strX, float strY){
		view.x = strX; view.y = strY;
		this.dir.x = dir.x;
		this.dir.y = dir.y;
		view.w = initW; view.h = initH;
		enableBool = true;
		state = 0;
		view.a = 1;
		stateTime = 0;
	}
	
	public void setDisable(){
		enableBool = false;
	}
	
	@Override
	public void draw(SpriteBatcher batcher) {
		if(!enableBool)
			return;
		batcher.drawSprite(view.x, view.y, view.w, view.h, 1, 1, 1, view.a, view.tr);
	}

	@Override
	public void update(float deltaTime) {
		if(!enableBool)
			return;
		switch(state){
			case 0:
				view.x += dir.x * deltaTime;
				view.y += dir.y * deltaTime;
				stateTime += deltaTime;
				if(stateTime > 1.0f){
					state = 1;
					enableBool = false;
				}
			break;
			
			case 1:
			break;
		}
	}
}
